package com.brillilab.service.core.inventory.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.brillilab.dao.mapper.inventory.InventoryDeleteRecordMapper;
import com.brillilab.domain.po.inventory.InventoryDeleteRecord;
import com.brillilab.service.core.inventory.IInventoryDeleteRecordService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 库存删除记录 服务实现类
 * </p>
 *
 * @author WuMenghao
 * @since 2019-05-23
 */
@Service
@Transactional
public class InventoryDeleteRecordServiceImpl implements IInventoryDeleteRecordService {

    @Resource
    private InventoryDeleteRecordMapper inventoryDeleteRecordMapper;

    @Override
    public int insertBatch(List<InventoryDeleteRecord> deleteRecords) {
        return inventoryDeleteRecordMapper.insertBatch(deleteRecords);
    }

    @Override
    public List<InventoryDeleteRecord> selectList(Long deviceId,Integer success) {
        return inventoryDeleteRecordMapper.selectList(
                new LambdaQueryWrapper<InventoryDeleteRecord>()
                        .eq(InventoryDeleteRecord::getDeviceId,deviceId)
                        .eq(InventoryDeleteRecord::getSuccess,success));
    }

    @Override
    public boolean updateBatch(List<InventoryDeleteRecord> deleteRecords) {
        return inventoryDeleteRecordMapper.updateBatch(deleteRecords) > 0;
    }

    @Override
    public boolean deleteByIds(List<Long> recordIds) {
        return inventoryDeleteRecordMapper.delete(new LambdaQueryWrapper<InventoryDeleteRecord>().in(InventoryDeleteRecord::getId,recordIds)) > 0;
    }
}
